package br.com.j7.jdesk.ui.bean;

import java.io.Serializable;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;

import br.com.j7.jdesk.library.serial.SComm;

/**
 * 
 * @author Edivando Alves
 *
 */
@ManagedBean   
@ApplicationScoped
public class SerialBean extends WebContext implements Serializable{

	private static final long serialVersionUID = 1L;
	
	private SComm serial;
	
	public SerialBean() {
		serial = new SComm("COM3", 9600, 1);
		serial.obterIdDaPorta();
		serial.abrirPorta();
		serial.addListener();
	}
	
	public void comand( String cmd ){
		serial.habilitarEscrita();
		serial.enviarString( cmd );
		serial.habilitarLeitura();
		serial.lerDados();

//	    try {
//	       Thread.sleep(500);  
//	    } catch (InterruptedException ex) {
//	       System.out.println("Erro na Thread: " + ex);
//	    }
	}
	
	

}
